package com.faithbj.device.service.impl;

import javax.annotation.Resource;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;

import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Service;

import com.faithbj.device.service.MailService;

@Service("mailService")
public class MailServiceImpl implements MailService
{
	@Resource
	private JavaMailSender mailSender;

	@Override
	public void sendEmail(String email,String subject,String text)
	{
		MimeMessage message = mailSender.createMimeMessage();
		MimeMessageHelper helper = new MimeMessageHelper(message);
		try
		{
			helper.setTo(email);
			helper.setSubject(subject);
			helper.setText(text);
			mailSender.send(message);
		}
		catch (MessagingException e)
		{
			e.printStackTrace();
		}
	}
}
